#include <bits/stdc++.h>

using namespace std;

class Solution
{
public:
    bool isPerfectSquare(int num)
    {
        long long l = 1, r = num;
        while (l < r)
        {
            long long mid = (r - l) / 2 + l;
            if ((long long)mid * mid < num)
            {
                l = mid + 1;
            }
            else
            {
                r = mid;
            }
        }
        if (l * l == num)
            return true;
        return false;
    }
};